package org.evan.spring.validator.two;

import org.junit.jupiter.api.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestUser {

    @Test
    public void testValid1() {
        ApplicationContext context = new AnnotationConfigApplicationContext(ValidatorConfig.class);
        MyValidation1 validation1 = context.getBean(MyValidation1.class);
        User user = new User();
        user.setName("evan");
        user.setAge(20);
        boolean message = validation1.validate(user);
        System.out.println(message);
    }

    @Test
    public void testValid2() {
        ApplicationContext context = new AnnotationConfigApplicationContext(ValidatorConfig.class);
        MyValidation2 validation2 = context.getBean(MyValidation2.class);
        User user = new User();
        user.setName("evan");
        user.setAge(-1);
        boolean message = validation2.validate(user);
        System.out.println(message);
    }
}
